﻿Imports System.Windows.Forms
Imports System.Data
Imports System.Data.OracleClient
Imports Barra

Public Class Frm_DetalleLogistica
    Dim VectorDeDatos(4) As TextBox
    'conexion para inicializar la barra del navegador
    Dim conexion As String = "Driver={Microsoft ODBC for Oracle};Server=xe;Uid=redes;Pwd=redes;"

    'query para el dgv
    Dim querydgv As String = " select  id_ruta as Ruta, id_entrega as Entrega, hora_ef as Hora, fecha_ef as Fecha, estado as Estado from TB_LOT_DETALLE_LOGISTICA order by id_entrega"
    'llenado del datagridview
    'DgvVehiculo.DataSource=llenarDGV(querydgv)
    'DgvEntrega.DataSource = LlenarDgv(querydgv)
    'variables a incluir si van a llenar un combo
    Dim querycombo As String = "SELECT id_ruta from TB_LOT_ruta"
    Dim valuecombo As String = "id_ruta" 'valor a insertar en tabla de acuerdo al combo
    Dim displaycombo As String = "id_ruta" 'valor a mostrar en el combo

    Dim querycombo1 As String = "SELECT id_entrega from TB_INA_ENTREGA"
    Dim valuecombo1 As String = "id_entrega" 'valor a insertar en tabla de acuerdo al combo
    Dim displaycombo1 As String = "id_entrega" 'valor a mostrar en el combo

    'variable para llevar la secuencia en el campo ID
    'Dim querysecuencia As String = "select max(ID_RUTA)+ 1 as ID_RUTA from TB_LOT_RUTA"
    ' Dim camposecuencia As String = "ID_RUTA"
    Public Function LlenarVector() As TextBox()
        VectorDeDatos(0) = TXTRUTA
        VectorDeDatos(1) = TXTEN
        VectorDeDatos(2) = TXTHORA
        VectorDeDatos(3) = TXTFECHA
        VectorDeDatos(4) = TXTEST
        Return VectorDeDatos
    End Function
    Private Sub Frm_DetalleLogistica_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        VectorDeDatos = LlenarVector()
        BarraNavegacion1.Inicializar("Driver={Microsoft ODBC for Oracle};Server=xe;Uid=redes; Pwd=redes;", "TB_LOT_DETALLE_LOGISTICA", VectorDeDatos)
        'llenar combobox en la declaracion
        Dim Cmb_estado() As String = {"Entregado", "Pendiente", "Ruta"}
        Cmbestado.Items.AddRange(Cmb_estado)
        'para llevar la secuencia del codigo
        funciones.llenarcombo(CMBRUTA, querycombo, valuecombo, displaycombo)
        funciones2.llenarcombo(CMBENT, querycombo1, valuecombo1, displaycombo1)
        'llenado del combo
        ' Dim temp As String = funciones.traersecuencia(querysecuencia, camposecuencia)
        'llenado del datagridview
        DGVDELO.DataSource = funciones.LlenarDgv(querydgv)
        'puse esto de funciones.traersecuencia porque sino me lo tiraba como error entonces llame la clase general primero
        'If temp = "" Then
        'TXTRUTA.Text = "1"
        ' Else
        ' TXTRUTA.Text = temp
        'End If
    End Sub
    Private Sub CMBRUTA_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMBRUTA.SelectedIndexChanged
        'para que el textbox oculto tome el valor del combo
        If CMBRUTA.ValueMember.Any Then
            TXTRUTA.Text = CMBRUTA.SelectedValue
        End If
    End Sub

    Private Sub CMBENT_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMBENT.SelectedIndexChanged
        'para que el textbox oculto tome el valor del combo
        If CMBENT.ValueMember.Any Then
            TXTEN.Text = CMBENT.SelectedValue
        End If
    End Sub

    Private Sub Cmbestado_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cmbestado.SelectedIndexChanged
        'para que el textbox oculto tome el valor del combo
        'If Cmbestado.ValueMember.Any Then
        TXTEST.Text = Cmbestado.SelectedItem
        ' End If
    End Sub
End Class